<?php
//申明一个人类，定义人所具有的一些基本属性和功能成员，作为父类
    class Person{
    	public $name;
    	public $sex;
    	public $age;

    	public function __construct($name = "",$sex = "男",$age = 1){;
    	$this->name = $name;
    	$this->sex  = $sex;
    	$this->age  = $age;
    }

        public function say(){
        	echo "我的名字: ".$this->name.",性别: ".$this->sex.",年龄: ".$this->age.".<br>";

        }

        public function run(){
        	echo $this->name."正在走路.<br>";
        }

    }

    //申明一个学生类，使用extends关键字扩展（继承）Person类
    class Student extends Person{
    	public $school;

    	public function study(){
    		echo $this->name."正在".$this->school."学习<br>";

    	}
    }

    //申明一个教师类，使用extends关键字扩展（继承）Student类
    class Teacher extends Student{
    	public $wage;

    	public function teaching(){
    		echo $this->name."正在".$this->school."教学,每月工资为".$this->wage.".<br>";
    	}
    }
    $teacher = new Teacher ("张三", "男", 40);


    $teacher1->school = "edu";
    $teacher1->wage = 3000;

    $teacher1->say();
    $teacher1->study();
    $teacher1->teaching();
    ?>

